package com.leapp.sk.viewdelegate.personal

import android.text.TextUtils
import android.widget.ImageView
import android.widget.TextView
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.ui.activity.personal.ContactCustomerServiceActivity
import com.leapp.sk.ui.activity.personal.SettingActivity

/**
 * 设置视图托管类
 * @author  chaohaipeng  on 2018/8/8.
 */
class SettingDelegate : BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_setting
    }

    /**
     * 设置缓存
     */
    fun setCache(cache:String){
        val tv_as_cache = getView<TextView>(R.id.tv_as_cache)
        if (!TextUtils.isEmpty(cache)){
            tv_as_cache.text=cache
        }

    }
    fun setPushbtn(isOpen:Boolean ){
        val iv_as_message_push= getView<ImageView>(R.id.iv_as_message_push)
        if(isOpen){
            iv_as_message_push.isSelected=true
        }else{
            iv_as_message_push.isSelected=false
        }

    }
    /**
     * 设置标题栏
     */
    fun setTitle(title:String?){
        val jtb_as_setting= getView<SKTopBar>(R.id.jtb_as_setting)
        if (!TextUtils.isEmpty(title)){
            jtb_as_setting.setTitle(title)
        }
        setEvent(jtb_as_setting)
    }

    /**
     * 设置设置事件
     */
    fun setEvent(topBar: SKTopBar){
        topBar?.setEventInterface(object : SKTopBar.EventInterface{
            override fun leftOnClick() {
                getActivity<SettingActivity>().finish()

            }
            override fun rightOnClick() {
            }

        })
    }

}